/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2018 All Rights Reserved.
 */
package com.citytsm.gateway.sdk.request;

import com.citytsm.gateway.sdk.utils.ApiConstants;
import com.citytsm.gateway.sdk.utils.TimeStampUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * API请求基础抽象类，实际请求需继承该类。子类需要覆盖getResponseClass方法，然后定义自己的业务参数即可
 */
public class GatewayRequest {

    @JsonIgnore
    private static final String VERSION = "1.0";
    @JsonIgnore
    private static final String SIGN_TYPE = "RSA2";
    @JsonIgnore
    public String reqId;
    @JsonIgnore
    protected String method;
    @JsonIgnore
    public String bizContent;

    public PtcApiRequest buildRequest(String appId) {
        PtcApiRequest request = new PtcApiRequest();
        request.setAppId(appId);
        request.setReqId(getReqId());
        request.setMethod(getMethod());
        request.setTimestamp(TimeStampUtil.getTimeStamp());
        request.setVersion(VERSION);
        request.setSignType(SIGN_TYPE);
        request.setCharset(ApiConstants.CHARSET_UTF8);
        request.setBizContent(getBizContent());
        return request;
    }

    public String getReqId() {
        return reqId;
    }

    public void setReqId(String reqId) {
        this.reqId = reqId;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getBizContent() {
        return bizContent;
    }

    public void setBizContent(String bizContent) {
        this.bizContent = bizContent;
    }
}